Skip to content

Conversation

@surajrdy-aws
Copy link

Problem

The inline test cannot be run consecutively with other tests in our suite since it switches its focus to the editorView and textEditorView. Each time the inline test is run, a new driver was launched with caused a new VSCode instance to instantiate.

The package.json should only target the .test.js files. Right now it targets all .js files in the directory.

The writeToTextEditor function is faulty since it is wrongly indexed due to its element not being accessed before counting and referencing its indices within code.

Solution

Implemented an after function which correctly switches back to our webviewView (AmazonQ). Added the true inline test into the suite and fixed driver problem.

Changed the path referenced in the package.json to .test.js files.

Fixed the writeToTextEditor function such that it includes a "dummy" space input into the textEditor and then counts the number of indices of lines. This then writes the desired text within the correct line without problems.


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@surajrdy-aws surajrdy-aws requested a review from a team as a code owner August 1, 2025 19:34
@github-actions
Copy link

github-actions bot commented Aug 1, 2025

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@surajrdy-aws surajrdy-aws changed the title fix(amazonq): Inline test after function addition fix(amazonq): Inline test after function addition, writeToTextEditor fix, and package.json pathing fix Aug 1, 2025
// Switch back to Webview Iframe when dealing with external webviews from Amazon Q.
await editorView.closeAllEditors()
await webviewView.switchToFrame()
testContext.webviewView = webviewView

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line for setting the testContext to webview needed? In the sense that the webview isn't being update or changed so should the state be updated?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh smart, yeah that isn't needed

const input = new InputBox()
await input.sendKeys('Write a simple sentece')
await input.sendKeys('Generate the fibonacci sequence through iteration')
await input.sendKeys(Key.ENTER)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this enter now accept the generation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it does not, but it is required for us to get out of the suggestion decision messing up any following clean ups

* @returns Promise<void>
*/
export async function writeToTextEditor(textEditor: TextEditor, text: string): Promise<void> {
await textEditor.typeTextAt(1, 1, ' ')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the reason why we need a space, but should we add a comment since its not obvious?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! So with this PR can we run all the tests together?

const driver = textEditor.getDriver()
await pressKey(driver, 'ENTER')
await pressKey(driver, 'TAB')
await sleep(8000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this sleep for? 8 seconds sounds like a lot

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the sleep is for waiting for the AmazonQ response to be generated. I realized its never always the same and can take sometime to either reason or just start coding right away. 8 seconds seems like the sweet spot for leeway for waiting for a response to be generated fully on other devices as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Is there a way we can wait dynamically with a cap? Like basically poll every 1 second until the response shows up the in the DOM. I think this general util will be helpful for other areas as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will look into it!


const textAfter = await textEditor.getText()
assert(textAfter.length > textBefore.length, 'Amazon Q should have generated code')
assert(textAfter.includes('fibonacci'), 'Generated code should contain fibonacci logic')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be potentially flaky? Wondering if the model ever generates a solution where they use fib or hallucinates something.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed!

Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid the sleep, and create some type of waiting utility, but otherwise this LGTM.

@surajrdy-aws surajrdy-aws enabled auto-merge (squash) August 4, 2025 18:22
@surajrdy-aws surajrdy-aws disabled auto-merge August 4, 2025 18:59
@surajrdy-aws
Copy link
Author

/retryBuilds

@surajrdy-aws surajrdy-aws merged commit 4080c31 into aws:feature/ui-e2e-tests Aug 4, 2025
49 of 53 checks passed
laura-codess pushed a commit to laura-codess/aws-toolkit-vscode that referenced this pull request Aug 10, 2025
…fix, and package.json pathing fix (aws#7800)

## Problem
The inline test cannot be run consecutively with other tests in our
suite since it switches its focus to the editorView and textEditorView.
Each time the inline test is run, a new driver was launched with caused
a new VSCode instance to instantiate.

The `package.json` should only target the `.test.js` files. Right now it
targets all .js files in the directory.

The `writeToTextEditor` function is faulty since it is wrongly indexed
due to its element not being accessed before counting and referencing
its indices within code.

## Solution
Implemented an `after` function which correctly switches back to our
webviewView (AmazonQ). Added the true inline test into the suite and
fixed driver problem.

Changed the path referenced in the `package.json` to `.test.js` files. 

Fixed the `writeToTextEditor` function such that it includes a "dummy"
space input into the textEditor and then counts the number of indices of
lines. This then writes the desired text within the correct line without
problems.

---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
laura-codess pushed a commit to laura-codess/aws-toolkit-vscode that referenced this pull request Aug 11, 2025
…fix, and package.json pathing fix (aws#7800)

## Problem
The inline test cannot be run consecutively with other tests in our
suite since it switches its focus to the editorView and textEditorView.
Each time the inline test is run, a new driver was launched with caused
a new VSCode instance to instantiate.

The `package.json` should only target the `.test.js` files. Right now it
targets all .js files in the directory.

The `writeToTextEditor` function is faulty since it is wrongly indexed
due to its element not being accessed before counting and referencing
its indices within code.

## Solution
Implemented an `after` function which correctly switches back to our
webviewView (AmazonQ). Added the true inline test into the suite and
fixed driver problem.

Changed the path referenced in the `package.json` to `.test.js` files. 

Fixed the `writeToTextEditor` function such that it includes a "dummy"
space input into the textEditor and then counts the number of indices of
lines. This then writes the desired text within the correct line without
problems.

---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants